#define _CRT_SECURE_NO_WARNINGS 1

class Solution {
public:
    int finalPositionOfSnake(int n, vector<string>& commands) {
        int right = 0, down = 0;
        for (auto str : commands)
        {
            if (str == "RIGHT") right++;
            else if (str == "LEFT") right--;
            else if (str == "DOWN") down++;
            else if (str == "UP") down--;
        }
        return right + down * n;
    }
};